$(document).on('click','#login',function () {
    var username = document.getElementById('username').value;
    var password = document.getElementById('password').value;
    var captcha = document.getElementById('captcha').value;
    $.ajax({
        type:"post",
        url:"/login",
        data:{
            "username":username,
            "password":password,
            "captcha":captcha,
        },
        success:function (f) {
            if(f.code==0){
                location.href = "/index"
            }else {
                layer.msg(f.msg);
                var img=document.getElementById("verifyCode");
                img.src="/captcha/getCode?"+new Date().getTime();
            }
        }
    })

})


$(document).on('click','#changeCode',function(){
    var img=document.getElementById("verifyCode");
    img.src="/captcha/getCode?"+new Date().getTime();
});